﻿<UserControl x:Class="ModernAudioTagger.Pages.TagPreviewPage"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:mui="http://firstfloorsoftware.com/ModernUI"
             xmlns:converter="clr-namespace:ModernAudioTagger.Converter"
             xmlns:provider="clr-namespace:ModernAudioTagger.Provider"
             xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
             xmlns:ei="http://schemas.microsoft.com/expression/2010/interactions"
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300">
    
    <UserControl.DataContext>
        <Binding Source="{x:Static provider:ViewModelLocator.Instance}" Path="TrackTagVM" />
    </UserControl.DataContext>

    <UserControl.Resources>
        <converter:FilenameConverter x:Key="filenameConverter" />
    </UserControl.Resources>

    <Grid Style="{StaticResource ContentRoot}">

        
        <DockPanel>
            <TextBlock 
                Style="{StaticResource Heading1}" 
                Text="Preview" 
                HorizontalAlignment="Center" 
                DockPanel.Dock="Top" />
            <StackPanel DockPanel.Dock="Bottom" Orientation="Horizontal" HorizontalAlignment="Center">
                <Button Margin="{StaticResource DefaultMargin}" Width="100" x:Name="btOk" Command="{Binding StartTagCommand}" Click="btOk_Click">
                    <StackPanel Orientation="Horizontal">
                        <TextBlock>Apply</TextBlock>
                        <Path Margin="{StaticResource DefaultLeftMargin}" Width="10" Height="10" Stretch="Uniform" Fill="#FF000000" Data="{StaticResource applyPathData}"/>
                    </StackPanel>
                </Button>
                <Button  Margin="{StaticResource DefaultMargin}" Width="100" x:Name="btCancel" Click="btCancel_Click">
                    <StackPanel Orientation="Horizontal">
                        <TextBlock>Cancel</TextBlock>
                        <Path Margin="{StaticResource DefaultLeftMargin}" Width="10" Height="10" Stretch="Uniform" Fill="#FF000000" Data="{StaticResource cancelPathData}" />
                    </StackPanel>
                </Button>
            </StackPanel>

            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="50*"></ColumnDefinition>
                    <ColumnDefinition Width="50*"></ColumnDefinition>
                </Grid.ColumnDefinitions>

                <ListView                     
                    BorderThickness="1"
                    BorderBrush="{DynamicResource SeparatorBackground}"
                    SelectionMode="Single"
                    FontSize="{StaticResource SmallFontSize}"                 
                    ItemsSource="{Binding TracksToTag}"
                    x:Name="lv_leftlist"
                    >
                    <ListView.View>
                        <GridView>
                            <GridViewColumn Header="#" Width="Auto" DisplayMemberBinding="{Binding Track, StringFormat='00', Mode=OneTime}" />
                            <GridViewColumn Header="Title" DisplayMemberBinding="{Binding Title, Mode=OneTime}" />
                        </GridView>
                    </ListView.View>
                </ListView>


                <ListView         
                    Grid.Column="1"
                    BorderThickness="1"
                    BorderBrush="{DynamicResource SeparatorBackground}"
                    FontSize="{StaticResource SmallFontSize}" 
                    SelectionMode="Single"                    
                    ItemsSource="{Binding FilesToTag}"      
                    x:Name="lv_rightlist"
                >
                    <ListView.View>
                        <GridView>
                            <GridViewColumn Header="Name" DisplayMemberBinding="{Binding FileName, Converter={StaticResource filenameConverter}}" />
                        </GridView>
                    </ListView.View>
                </ListView>
            </Grid>
        </DockPanel>

        <i:Interaction.Triggers>
            <!--
            <i:EventTrigger EventName="SelectionChanged" SourceName="lv_rightlist">
                <ei:ChangePropertyAction TargetName="lv_leftlist" PropertyName="SelectedIndex" Value="{Binding ElementName=lv_rightlist, Path=SelectedIndex}" />
            </i:EventTrigger>
            -->
            <i:EventTrigger EventName="SelectionChanged" SourceName="lv_leftlist">
                <ei:ChangePropertyAction TargetName="lv_rightlist" PropertyName="SelectedIndex" Value="{Binding ElementName=lv_leftlist, Path=SelectedIndex}" />
            </i:EventTrigger>
        </i:Interaction.Triggers>

    </Grid>
</UserControl>
